package com.itheima.tlias84.mapper;

import com.itheima.tlias84.dto.ReportStuDegreeDTO;
import com.itheima.tlias84.dto.SelectStudentByIdDTO;
import com.itheima.tlias84.dto.SelectStudentDTO;
import com.itheima.tlias84.po.InsterStudentParam;
import com.itheima.tlias84.po.SelectStudentPageParam;
import com.itheima.tlias84.po.UpdateStudentParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {
    List<SelectStudentDTO> selectStudentByPage(SelectStudentPageParam param);

    int insertStudent(InsterStudentParam param);

    int batchDelete(List<Integer> ids);

    SelectStudentByIdDTO selectStudentById(Integer id);

    int updateStudent(UpdateStudentParam param);

    int violation(Integer id);

    @Select("select count(degree) as value,case degree when 1 then'初中' when 2 then'高中' when 3 then'大专' when 4 then'本科' when 5 then'硕士' when 6 then'博士' end as name from student group by degree")
    List<ReportStuDegreeDTO> countStuByDegree();

    @Select("select clazz_id from student")
    List<Integer> countStuByClazzId();
}
